<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:panelGroup >
            <h:form id="form"  >
                <p:growl id="msg" autoUpdate="true" />
                <p:panel header="Manage Timed Item (Theatre Only)" >
                    <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop" >
                        <h:panelGrid id="gpSelect" columns="1"  >
                            <p:panel header="Search Timed Item" >
                                <h:panelGrid id="gpSelectText" >
                                    <p:selectOneListbox   id="lstSelect"   value="#{timedItemController.current}" style="min-width: 223px; height: 300px;">
                                        <f:selectItems  value="#{timedItemController.selectedTheatreItems }" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                        <p:ajax event="change"   update="gpDetail" process="@this" >
                                        </p:ajax>
                                    </p:selectOneListbox>


                                </h:panelGrid>
                                <h:panelGrid id="gpSelectButtons" columns="3"  >
                                    <h:commandButton id="btnAdd" value="Add" action="#{timedItemController.prepareTheatreTimeServiceAdd() }" styleClass="buttons" >
                                        <f:ajax render="btnAdd  btnDelete btnSave   lstSelect gpDetail " execute="" >
                                        </f:ajax>
                                    </h:commandButton>

                                    <h:commandButton id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                return false;" action="#{timedItemController.delete()}"  value="Delete"  >
                                    </h:commandButton>


                                </h:panelGrid>
                            </p:panel>
                        </h:panelGrid  >

                        <p:panel header="Edit Details">
                            <f:facet name="header" >
                                <h:outputLabel value="Edit Details" ></h:outputLabel>

                                <p:commandButton style="float:right;" id="btnSave" value="Save"  action="#{timedItemController.saveSelected()}" styleClass="buttons" 
                                                 process="gpDetail btnSave" update="lstSelect msg"   >
                                </p:commandButton>
                                <p:defaultCommand target="btnSave"/>
                            </f:facet>
                            <h:panelGrid id="gpDetail" columns="1">
                                <h:panelGrid id="gpDetailText" columns="2" rendered="#{timedItemController.current ne null}">
                                    <h:outputText id="lblName" value="Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtName" value="#{timedItemController.current.name}" required="true" ></h:inputText>
                                    <h:outputText id="lblAddress" value="Printing Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtAddress"  class="pdInputText" value="#{timedItemController.current.printName}"  ></h:inputText>
                                    <h:outputText id="lblFullName" value="Full Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtFullName"  class="pdInputText" value="#{timedItemController.current.fullName}"  ></h:inputText>


                                    <h:outputText value="Institution" ></h:outputText>
                                    <h:selectOneListbox id="cmbIns" size="1" value="#{timedItemController.current.institution}" >
                                        <f:selectItem itemLabel="Please select a Institution"/>
                                        <f:selectItems value="#{institutionController.companies}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                        <f:ajax execute="cmbIns" render="cmbDep" event="change"/>   
                                    </h:selectOneListbox>
                                    <h:outputText value="Department" ></h:outputText>
                                    <h:selectOneListbox id="cmbDep" size="1" value="#{timedItemController.current.department}" >
                                        <f:selectItem itemLabel="Please select a Department"/>
                                        <f:selectItems value="#{timedItemController.institutionDepatrments}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </h:selectOneListbox>

                                    <h:outputText value="Inward Charge Category" ></h:outputText>
                                    <p:selectOneMenu id="cmbInward" value="#{timedItemController.current.inwardChargeType}" >
                                        <f:selectItem itemLabel="Please select Charge"/>
                                        <f:selectItems value="#{enumController.inwardChargeTypesForSetting}" var="i" itemLabel="#{i.label}" itemValue="#{i}"/>
                                    </p:selectOneMenu>
                                    
                                    <h:outputText value="Category" ></h:outputText>
                                    <p:selectOneMenu id="cmbCat" value="#{timedItemController.current.category}" >
                                        <f:selectItem itemLabel="Please select a Category"/>
                                        <f:selectItems value="#{timedItemCategoryController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                    </p:selectOneMenu>

                                    <h:outputText value="" ></h:outputText>
                                    <p:selectBooleanCheckbox value="#{timedItemController.current.userChangable}" itemLabel="Can change Rate"/>

                                    <h:outputText value="" ></h:outputText>
                                    <p:selectBooleanCheckbox value="#{timedItemController.current.discountAllowed}" itemLabel="Discount Allowed"/>
                                    
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid>
                </p:panel>
            </h:form>

        </h:panelGroup>
    </ui:define>



</ui:composition>
